#include "MovableObject.h"

MovableObject::MovableObject():
Object()
{
    //ctor
//    m_animCreature = new AnimCreature(this);
}

MovableObject::~MovableObject()
{
    //dtor
    delete m_animCreature;
}



/** @brief clear
  *
  * @todo: document this function
  */
void MovableObject::clear()
{

}

/** @brief update
  *
  * @todo: document this function
  */
void MovableObject::update(double timeSinceLastFrame)
{

}

/** @brief init
  *
  * @todo: document this function
  */
void MovableObject::init()
{

}

/** @brief getType
  *
  * @todo: document this function
  */
OBJ_TYPE MovableObject::getType()
{
return OBJ_TYP_MOVABLE;
}

/** @brief addWayPoints
  *
  * @todo: document this function
  */
void MovableObject::addWayPoints(std::list<Ogre::Vector2> list)
{
    m_waypoints.clear();
    //list.pop_front();
    m_waypoints.merge(list);


}

void MovableObject::clearWayPoints()
{
    m_waypoints.clear();

}

/** @brief getDistanceFromWalkTarget
  *
  * @todo: document this function
  */
float MovableObject::getDistanceFromWalkTarget()
{
//return m_walkTarget.distance(getPosition());
return 0;
}

/** @brief setPosition
  *
  * @todo: document this function
  */
void MovableObject::setPosition(Ogre::Vector2 _position)
{

  /*  m_position = _position;
  //  m_animCreature.setPosition(addYtoVector2(_position,m_Yoffset));


    if (m_node)
        m_node->setPosition(Ogre::Vector3(m_position.x,m_Yoffset,m_position.y));

*/
}




void MovableObject::walkTo(Ogre::Vector2 target)
{
   /*     m_walkTarget = target;
        m_animCreature->setDestination(addYtoVector2(m_walkTarget,m_Yoffset));
        float distance = m_walkTarget.distance(m_position);
        float seuil = 0.1f;
        if(distance <= seuil)
        {
            m_waypoints.pop_front();
        }





      //  Ogre::Vector3 _pos = m_animCreature->getPosition();
     //   m_position = removeYtoVector3(_pos);
        if (m_node)
        {
            m_node->setPosition(addYtoVector2(m_position, m_Yoffset));
            m_node->resetOrientation();
            Ogre::Math::setAngleUnit(Ogre::Math::AU_DEGREE);
            m_node->yaw(Ogre::Angle(90), Ogre::Node::TS_LOCAL);
            Ogre::Math::setAngleUnit(Ogre::Math::AU_RADIAN);
            m_node->yaw(Ogre::Angle(-m_animCreature->getAngleHeading()), Ogre::Node::TS_LOCAL);
            //  m_node->rotate(Ogre::Vector3::UNIT_Y, Ogre::Radian(Ogre::Real(m_animCreature.getAngleHeading())), Ogre::Node::TS_LOCAL);
        }
        */
}
